<?php
namespace Home\Model;
use Think\Model;

class AppVersionLogModel extends BaseModel {

    protected $tableName = 'tp_app_version_log';


    /**
     * @Desc  : 查询升级版本
     * @Author：quyang
     * @Param ：$deviceType 升级类型 （0.android 1.IOS）  $channel 升级渠道  $type版本类型  1.稳定版  2.体验版
     * @Time  ：2017/3/23 14:11
     * @Update：2017/3/23
     **/
    public function queryUpdateApp( $deviceType , $channel , $type, $platform = 0,$status)
    {

        $where['f_update_type'] = $deviceType;
        $where['f_channel'] = $channel;
        if ( $type != 3 )
        {
            $where['f_type'] = $type;
        }

        if($status==2){
            $map['f_status']  = array('lt',2);
        }else{
            $map['f_status']=1;
        }

        //哪种平台 0普通版 1专业版 2 pda 3 三合一
        $where['platform'] = $platform;

        return $this->where( $where )
            ->field('
                    f_id as fId,
                    f_version_code as fVersionCode,
                    f_version_name as fVersionName,
                    f_download_url as fDownloadUrl,
                    f_update_des as fUpdateDes,
                    f_md5_code as fMd5Code,
                    f_update_status as fUpdateStatus,
                    f_channel as fChannel,
                    f_update_type as fUpdateType,
                    f_type as fType,
                    f_release_time,
                    f_status
					')
            ->where($map)
            ->order('f_version_code desc')
            ->select();

    }

}